package controller

import (
	"github.com/gin-gonic/gin"
	"lab.com/biz"
	"lab.com/request"
)

type cCooperation struct {
	APIBase
}

// Cooperation .
var Cooperation = cCooperation{}

// List return cooperation list (all user)
func (coo *cCooperation) List(c *gin.Context) {
	inputParams := request.CooperationListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	res, err := biz.Cooperation.List(c, inputParams)
	coo.Resp(c, res, err)
}

// Detail return cooperation detail (all user)
func (coo *cCooperation) Detail(c *gin.Context) {
	inputParams := request.CooperationDetailReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	res, err := biz.Cooperation.Detail(c, inputParams)
	coo.Resp(c, res, err)
}

// Add return cooperation add (admin)
func (coo *cCooperation) Add(c *gin.Context) {
	inputParams := request.CooperationAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	err := biz.Cooperation.Add(c, inputParams)
	coo.Resp(c, nil, err)
}

// Delete return cooperation delete (admin)
func (coo *cCooperation) Delete(c *gin.Context) {
	inputParams := request.CooperationDeleteReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	err := biz.Cooperation.Delete(c, inputParams)
	coo.Resp(c, nil, err)
}

// Edit return cooperation edit (admin)
func (coo *cCooperation) Edit(c *gin.Context) {
	inputParams := request.CooperationEditReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	err := biz.Cooperation.Edit(c, inputParams)
	coo.Resp(c, nil, err)
}

// Show return cooperation show (admin)
func (coo *cCooperation) Show(c *gin.Context) {
	inputParams := request.CooperationShowReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	err := biz.Cooperation.Show(c, inputParams)
	coo.Resp(c, nil, err)
}

// Home return cooperation ome (admin)
// func (coo *cCooperation) Home(c *gin.Context) {
// 	inputParams := request.CooperationHomeReq{}
// 	if err := inputParams.CheckInputParams(c); err != nil {
// 		coo.Resp(c, nil, err)
// 		return
// 	}

// 	err := biz.Cooperation.Home(c, inputParams)
// 	coo.Resp(c, nil, err)
// }

// ListInManage return cooperation list in manage (admin)
func (coo *cCooperation) ListInManage(c *gin.Context) {
	inputParams := request.CooperationListInManageReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		coo.Resp(c, nil, err)
		return
	}

	res, err := biz.Cooperation.ListInManage(c, inputParams)
	coo.Resp(c, res, err)
}
